﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using WebSite.ErrorMails;

public partial class WebSite_t_error : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserId"] == null || Session["UserIdentity"].ToString() != "1")
        {
            Response.Redirect("Default.aspx", false);
            return;
        }
        if (Session["ErrorMessage"] == null || Session["AtPage"] == null)
        {
            Response.Redirect("t_data_contrast.aspx", false);
            return;
        }
        //跳转页面到首页。
        string strRedirectPage = "Default.aspx";
        string strRedirectTime = "1";
        string strRedirect = string.Format("{0};url={1}", strRedirectTime, strRedirectPage);
        Response.AddHeader("refresh", strRedirect);

        if (!IsPostBack)
        {


            string userid = Session["UserId"].ToString();
            string ErrorMessage = Session["ErrorMessage"].ToString();
            string AtPage = Session["AtPage"].ToString();
            //将错误信息取出来后则从session里面删除掉。
            Session.Remove("ErrorMessage");
            Session.Remove("AtPage");
            ErrorMessageLabel.Text = ErrorMessage;
            ErrorMailSend Mailsender = new ErrorMailSend();
            //发送错误信息给开发者团队。
            Mailsender.SendErrorMail(ErrorMessage, userid, AtPage);
        }
    }
}
